package utils

import (
	"crypto/md5"
	"encoding/hex"
	"golang.org/x/crypto/bcrypt"
)

// EncryptPassword bcrypt加密密码
func EncryptPassword(pass string) string {
	buf, err := bcrypt.GenerateFromPassword([]byte(pass), bcrypt.DefaultCost)
	if err != nil {
		return ""
	}
	return string(buf)
}

func Md5(data []byte) string {
	h := md5.New()
	h.Write(data)
	buf := h.Sum(nil)
	return hex.EncodeToString(buf)
}
